package com.ajnp.springcloud.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Component
//@FeignClient 注解指定通过服务名获取 服务中的方法  fallback 指定全局的服务降级所在类
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT", fallback = PaymentFallbackService.class)
// fallback 处理的是连接服务端时的服务降级
public interface PaymentHystrixService {

    //正常服务
    @GetMapping("/payment/hystrix/ok/{id}")
    public String is_OK(@PathVariable("id") Integer id);

    //模拟复杂方法的
    @GetMapping("/payment/hystrix/out/{id}")
    public String no_OK(@PathVariable("id") Integer id);

    //服务熔断
    @GetMapping("/payment/hystrix/rd/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id);


}
